{// 加载头部公共文件 }
<include file="Public:header" />
<script>
$(function(){
	$("#chkall").bind("click", function () {
		var chk=this.checked;
		$("[name = chkid]:checkbox").each(function () {
			if ($(this).attr("disabled") != "disabled") {
				$(this).prop('checked', chk);
			}
		});
	});
	$(".userdelete").on("click",function(){
		if(confirm("确定要删除这个用户吗？预约记录将被一并删除！")){
			$.ajax({
				url:$(this).attr("data-url"),type:"get",dataType:"json",cache:false
			}).done(function(data){
				if(data.status==1){
					location.reload();
				}else{
					alert(data.info);
					return false;
				}
			})
		}
	})	
	$("#search").on("click",function(){
		var url="{:U('admin/user/index/')}";
		var query  = $('#formuser').find('input').serialize();
		location.href=url+"&"+query;
	})
	$("#start,#stop").on("click",function(){
		 var idsvalue = "";
		$("[name='chkid']").each(function (i) {
			if ($(this).is(':checked')) {
				if (idsvalue != "") idsvalue += ",";
				idsvalue += $(this).attr("value");
			}
		});
		if(idsvalue!=""){
			if(confirm("确定操作选中项吗？")){
				$.ajax({
					url:"{:U('admin/user/update/')}",type:"post",dataType:"json",cache:false,data:{uid:idsvalue,status:$(this).val()}
				}).done(function(data){
					if(data.status){
						location.reload();
					}
				});

			}
		}
	})
})
</script>
<div class="container">
	<form class="form-inline" role="form" action="{:U('admin/user/index/')}" method="get" id="formuser">
	  <div class="form-group">
		<label class="sr-only" for="username">用户名</label>
		<input type="text" class="form-control" id="username" name="username" placeholder="用户名" style="width:120px;">
	  </div>
	  <div class="form-group">
		<label class="sr-only" for="id">身份证号</label>
		<input type="text" class="form-control" id="id" name="id" placeholder="身份证号" style="width:120px;">
	  </div>
	  <div class="form-group">
		<label class="sr-only" for="truename">真实姓名</label>
		<input type="text" class="form-control" id="truename" name="truename" placeholder="真实姓名" style="width:120px;">
	  </div>

	  <button type="button" class="btn btn-primary" id="search">搜索</button>&nbsp;
	  <button type="button" class="btn btn-primary navbar-btn" id="start" value="0">启用</button>&nbsp;
	  <button type="button" class="btn btn-danger navbar-btn" id="stop" value="1">拉黑</button>
	 
	</form>
	<br>

	<table class="table table-striped">
		<tr>
			<th><input type="checkbox" id="chkall"></th><th>用户名</th><th>真实姓名</th><th>身份证</th><th>性别</th><th>手机</th><th>注册日期</th><th>状态</th><th>操作</th>
		</tr>
		<volist name="list" id="vo">
		<tr>
			<th><input type="checkbox" name="chkid" value="{$vo.uid}"></th>
			<td>{$vo.username}</td>
			<td id="truename_{$vo.uid}">{$vo.truename}</td>
			<td id="id_{$vo.uid}">{$vo.id}</td>	
			<td id="sex_{$vo.uid}">{$vo['type']|getSex}</td>
			<td id="mobile_{$vo.uid}">{$vo.mobile}</td>
			<td id="addtime_{$vo.uid}">{$vo['addtime']|toDate}</td>
			<td>{$vo['status']|getUserState}</td>
			<td><a href="{:U('admin/appoint/index/',array('uid'=>$vo['uid']))}" class="btn btn-primary btn-xs">挂号记录</a>&nbsp;
			<a href="#" class="btn btn-danger btn-xs userdelete" data-url="{:U('admin/user/delete/',array('uid'=>$vo['uid']))}">删除</a></td>
		</tr>
		</volist>
	</table>
	
	<ul class="pagination">{$page}</ul>
</div> <!-- /container -->
<!-- channelResDialog start -->
<div id="userDialog" class="modal" tabindex="-1">

	<form class="form-horizontal" action="{:U('admin/user/save/')}" method="post">
	<div class="modal-dialog" style="width: 600px;">
		<div class="modal-content">
			<div class="modal-header">
				<h4>添加用户</h4>
			</div>
			<div class="modal-body">
			<input type="hidden" value="0" name="did" id="did"/>
			  <div class="form-group">
				<label  class="col-sm-3 control-label" for="truename">真实姓名</label>
				<div class="col-sm-9">
				<input type="text" class="form-control input-sm" id="truename" name="name" placeholder="真实姓名">
				</div>
			  </div>
			  <div class="form-group">
				<label  class="col-sm-3 control-label" for="id">身份证</label>
				<div class="col-sm-9">
				<input type="text" class="form-control input-sm" id="id" name="id" placeholder="身份证">
				</div>
			  </div>		  
			  
			  <div class="form-group">
				<label  class="col-sm-3 control-label" for="type">性别</label>
				<div class="col-sm-9">
				<label class="radio-inline">
				  <input type="radio" id="typ0" name="type" value="0" checked> 男
				</label>
				<label class="radio-inline">
				  <input type="radio" id="type1" name="type" value="1"> 女
				</label>
				</div>
			  </div>

			  <div class="form-group">
				<label  class="col-sm-3 control-label" for="id">医保号</label>
				<div class="col-sm-9">
				<input type="text" class="form-control input-sm" id="id" name="id" placeholder="医保号">
				</div>
			  </div>
			  
			  <div class="form-group">
				<label  class="col-sm-3 control-label" for="mobile">手机号</label>
				<div class="col-sm-9">
				<input type="text" class="form-control input-sm" id="id" name="mobile" placeholder="mobile">
				</div>
			  </div>
			  <div class="form-group">
				<label  class="col-sm-3 control-label" for="address">地址</label>
				<div class="col-sm-9">
				<textarea class="form-control input-sm" rows="2" id="address" name="address"></textarea>
				</div>
			  </div>
			  <div class="form-group">
				<label  class="col-sm-3 control-label" for="mobile">验证码</label>
				<div class="col-sm-9">
				<input type="text" class="form-control input-sm" id="id" name="mobile" placeholder="mobile">
				</div>
			  </div>
			</div>
			<div class="modal-footer">
				<input class="btn btn-default" value="取消" id="close" type="button">
				<input class="btn btn-primary" type="submit" value="确认">
			</div>
			
		</div>
	</div>
	</form>	
</div>

<!-- 主页面结束 -->
{// 加载尾部公共文件 }
<include file="Public:footer" />